#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>
#include <QDebug>
#include <QButtonGroup>
int count = 0;
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //创建图标对象
    QIcon icon(":/1.jpg");
    ui->pushButton_icon->setIcon(icon);
    //设置图标尺寸
    ui->pushButton_icon->setIconSize((QSize(50,50)));

    ui->iconbutton->setIcon(icon);
    ui->iconbutton->setIconSize((QSize(70,70)));
    //ui->iconbutton->setIconSize((QSize(140,140)));

    //用快捷键(空格)点击该按钮，参数可改为"w","q"，也可以是组合键

    //ui->iconbutton->setShortcut(QKeySequence("space"));
    ui->iconbutton->setShortcut(QKeySequence("ctrl+space"));

    //还可以通过案件的枚举来设置按键快捷键
    ui->iconbutton->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_W));

    //连发功能
    ui->iconbutton->setAutoRepeat(true);//允许连发

    /***********************
    * RadioButton
    ************************/
    //禁用按钮
    ui->radioButton_other->setCheckable(false);
    ui->radioButton_other->setEnabled(false);
    //也可以是
    //ui->radioButton_other->setDisabled(false);

    //ButtonGroup
    QButtonGroup* group1 = new QButtonGroup(this);
    QButtonGroup* group2 = new QButtonGroup(this);
    QButtonGroup* group3 = new QButtonGroup(this);

    group1->addButton(ui->radioButton_5);
    group1->addButton(ui->radioButton_6);

    group2->addButton(ui->radioButton_7);
    group2->addButton(ui->radioButton_8);

    group3->addButton(ui->radioButton_9);
    group3->addButton(ui->radioButton_10);
<<<<<<< HEAD





=======
>>>>>>> 60ad0d41bcf6a5e3b293a75af8fceebec63fe8ce
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_icon_clicked()
{
    qDebug() << "icon_button has clicked: " << count++;
}

void Widget::on_iconbutton_clicked()
{
    Widget::on_pushButton_icon_clicked();
    //通过快捷方式点击pushButton_icon
}

void Widget::on_radioButton_male_clicked()
{
    ui->label->setText("您选择的性别为：男");
}

void Widget::on_radioButton_female_clicked()
{
    ui->label->setText("您选择的性别为：女");
}

void Widget::on_radioButton_other_clicked()
{
    ui->label->setText("您选择的性别为：其他");
}

void Widget::on_radioButton_clicked(bool checked)
{
    //此处checked表示当前radioButton的选中状态
    qDebug() << "clicked: " << checked;
}

void Widget::on_radioButton_2_pressed()
{
    qDebug() << "pressed";
}

void Widget::on_radioButton_3_released()
{
    qDebug() << "released";
}

void Widget::on_radioButton_4_toggled(bool checked)
{
    //checked状态发生改变，就会触发
    qDebug() << "toggled: " << checked;
}
<<<<<<< HEAD

/****************
 * CheckBox
 * ****************/

void Widget::on_pushButton_choose_clicked()
{
    QString result = "今天你的安排是：";
    if(ui->checkBox_study->isChecked())
        result += ui->checkBox_study->text() + " ";

    if(ui->checkBox_game->isChecked())
        result += ui->checkBox_game->text() + " ";

    if(ui->checkBox_work->isChecked())
        result += ui->checkBox_work->text() + " ";

    ui->label_choose->setText(result);
}
=======
>>>>>>> 60ad0d41bcf6a5e3b293a75af8fceebec63fe8ce
